package com.sh.data.engine.domain.common.model.domain;

import gudusoft.gsqlparser.TGSqlParser;
import gudusoft.gsqlparser.dlineage.dataflow.listener.DataFlowHandleAdapter;

import java.io.File;

public class LogRecord extends DataFlowHandleAdapter {
    public void setDate(String date) {
        this.date = date;
    }

    public void setTime(String time) {
        this.time = time;
    }

    public void setIp(String ip) {
        this.ip = ip;
    }

    public void setOs(String os) {
        this.os = os;
    }

    public void setBrowser(String browser) {
        this.browser = browser;
    }

    public void setDbVendor(String dbVendor) {
        this.dbVendor = dbVendor;
    }

    public void setSqlSize(long sqlSize) {
        this.sqlSize = sqlSize;
    }

    public void setStmtCount(long stmtCount) {
        this.stmtCount = stmtCount;
    }

    public void setFileSize(long fileSize) {
        this.fileSize = fileSize;
    }

    public void setParseSuccess(boolean parseSuccess) {
        this.parseSuccess = parseSuccess;
    }

    public void setTimeUsed(long timeUsed) {
        this.timeUsed = timeUsed;
    }

    public void setCount(boolean isCount) {
        this.isCount = isCount;
    }

    public void setRateLimit(boolean rateLimit) {
        this.rateLimit = rateLimit;
    }

    public void setErrorMessage(String errorMessage) {
        this.errorMessage = errorMessage;
    }

    public void setType(String type) {
        this.type = type;
    }

    public boolean equals(Object o) {
        if (o == this)
            return true;
        if (!(o instanceof LogRecord))
            return false;
        LogRecord other = (LogRecord) o;
        if (!other.canEqual(this))
            return false;
        Object this$date = getDate(), other$date = other.getDate();
        if ((this$date == null) ? (other$date != null) : !this$date.equals(other$date))
            return false;
        Object this$time = getTime(), other$time = other.getTime();
        if ((this$time == null) ? (other$time != null) : !this$time.equals(other$time))
            return false;
        Object this$ip = getIp(), other$ip = other.getIp();
        if ((this$ip == null) ? (other$ip != null) : !this$ip.equals(other$ip))
            return false;
        Object this$os = getOs(), other$os = other.getOs();
        if ((this$os == null) ? (other$os != null) : !this$os.equals(other$os))
            return false;
        Object this$browser = getBrowser(), other$browser = other.getBrowser();
        if ((this$browser == null) ? (other$browser != null) : !this$browser.equals(other$browser))
            return false;
        Object this$dbVendor = getDbVendor(), other$dbVendor = other.getDbVendor();
        if ((this$dbVendor == null) ? (other$dbVendor != null) : !this$dbVendor.equals(other$dbVendor))
            return false;
        if (getSqlSize() != other.getSqlSize())
            return false;
        if (getStmtCount() != other.getStmtCount())
            return false;
        if (getFileSize() != other.getFileSize())
            return false;
        if (isParseSuccess() != other.isParseSuccess())
            return false;
        if (getTimeUsed() != other.getTimeUsed())
            return false;
        if (isCount() != other.isCount())
            return false;
        if (isRateLimit() != other.isRateLimit())
            return false;
        Object this$errorMessage = getErrorMessage(), other$errorMessage = other.getErrorMessage();
        if ((this$errorMessage == null) ? (other$errorMessage != null) : !this$errorMessage.equals(other$errorMessage))
            return false;
        Object this$type = getType(), other$type = other.getType();
        return !((this$type == null) ? (other$type != null) : !this$type.equals(other$type));
    }

    protected boolean canEqual(Object other) {
        return other instanceof LogRecord;
    }

    public int hashCode() {
        int PRIME = 59;
        int result = 1;
        Object $date = getDate();
        result = result * 59 + (($date == null) ? 43 : $date.hashCode());
        Object $time = getTime();
        result = result * 59 + (($time == null) ? 43 : $time.hashCode());
        Object $ip = getIp();
        result = result * 59 + (($ip == null) ? 43 : $ip.hashCode());
        Object $os = getOs();
        result = result * 59 + (($os == null) ? 43 : $os.hashCode());
        Object $browser = getBrowser();
        result = result * 59 + (($browser == null) ? 43 : $browser.hashCode());
        Object $dbVendor = getDbVendor();
        result = result * 59 + (($dbVendor == null) ? 43 : $dbVendor.hashCode());
        long $sqlSize = getSqlSize();
        result = result * 59 + (int) ($sqlSize >>> 32L ^ $sqlSize);
        long $stmtCount = getStmtCount();
        result = result * 59 + (int) ($stmtCount >>> 32L ^ $stmtCount);
        long $fileSize = getFileSize();
        result = result * 59 + (int) ($fileSize >>> 32L ^ $fileSize);
        result = result * 59 + (isParseSuccess() ? 79 : 97);
        long $timeUsed = getTimeUsed();
        result = result * 59 + (int) ($timeUsed >>> 32L ^ $timeUsed);
        result = result * 59 + (isCount() ? 79 : 97);
        result = result * 59 + (isRateLimit() ? 79 : 97);
        Object $errorMessage = getErrorMessage();
        result = result * 59 + (($errorMessage == null) ? 43 : $errorMessage.hashCode());
        Object $type = getType();
        return result * 59 + (($type == null) ? 43 : $type.hashCode());
    }

    public String toString() {
        return "LogRecord(date=" + getDate() + ", time=" + getTime() + ", ip=" + getIp() + ", os=" + getOs() + ", browser=" + getBrowser() + ", dbVendor=" + getDbVendor() + ", sqlSize=" + getSqlSize() + ", stmtCount=" + getStmtCount() + ", fileSize=" + getFileSize() + ", parseSuccess=" + isParseSuccess() + ", timeUsed=" + getTimeUsed() + ", isCount=" + isCount() + ", rateLimit=" + isRateLimit() + ", errorMessage=" + getErrorMessage() + ", type=" + getType() + ")";
    }

    private String date = "";

    public String getDate() {
        return this.date;
    }

    private String time = "";

    public String getTime() {
        return this.time;
    }

    private String ip = "";

    public String getIp() {
        return this.ip;
    }

    private String os = "";

    public String getOs() {
        return this.os;
    }

    private String browser = "";

    public String getBrowser() {
        return this.browser;
    }

    private String dbVendor = "";

    private long sqlSize;

    private long stmtCount;

    private long fileSize;

    public String getDbVendor() {
        return this.dbVendor;
    }

    public long getSqlSize() {
        return this.sqlSize;
    }

    public long getStmtCount() {
        return this.stmtCount;
    }

    public long getFileSize() {
        return this.fileSize;
    }

    private boolean parseSuccess = true;

    private long timeUsed;

    public boolean isParseSuccess() {
        return this.parseSuccess;
    }

    public long getTimeUsed() {
        return this.timeUsed;
    }

    private boolean isCount = false;

    public boolean isCount() {
        return this.isCount;
    }

    private boolean rateLimit = false;

    public boolean isRateLimit() {
        return this.rateLimit;
    }

    private String errorMessage = "";

    public String getErrorMessage() {
        return this.errorMessage;
    }

    private String type = "";

    public String getType() {
        return this.type;
    }

    public LogRecord() {
    }

    public void startAnalyze(File file, long lengthOrCount, boolean isCount) {
        if (isCount) {
            this.isCount = true;
            this.fileSize = lengthOrCount;
        } else {
            this.sqlSize = lengthOrCount;
        }
    }

    public void startParse(File file, String sql) {
        if (this.isCount)
            this.sqlSize += sql.length();
    }

    public void endParse(boolean isSuccess) {
        if (!isSuccess)
            this.parseSuccess = isSuccess;
    }

    public void endAnalyzeDataFlow(TGSqlParser sqlparser) {
        this.stmtCount += sqlparser.getSqlstatements().size();
    }
}